<?

//Data loading
$title='REPORT BUDGET PROJECT';
$perush = 'PT. MASAJI PRAYASA CARGO';
$page   = 'PAGE';
$TableName = "tblproject";
$DEFINE_FONT=0;
$pdf=new PDFReport("P","mm","Letter");
$pdf->AddPage();
$Result = ReportList ("", "", "");
if ($Result) $pdf->ReportTable($Result);
$pdf->Output();



function ReportList ($Space, $Index, $ParentID) {
	global $RS,$Index,$TableName,$curr;
	$DBConnection   = new mydb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
	if (!$Index) $Index = 0;
 
    $project_id = $_REQUEST['project_id'];
        
	$SQL = " SELECT * FROM ".$TableName." WHERE project_id ='".$project_id."' ";

    $SQL .= " ORDER BY project_id DESC ";

    $MyResult = $DBConnection->dbc->get_results($SQL,ARRAY_A);
    return $MyResult;
    
}




class PDFReport extends PDF {

    function Header() 
    {
        global $title,$perush,$page,$DEFINE_FONT,$curr;
         
        //Initial Date        
		$SystemDate = date("d/m/Y");		
		//End Initial Date
        
        if ($DEFINE_FONT==0) {
            $this->AddFont('arialn','','arialn.php');
            $DEFINE_FONT=1;
        }
        $this->SetFont('arialn','',12);
		$this->Cell(195,5,$perush,0,1,'C',0);
		$this->Cell(195,5,$title,0,1,'C',0);
						
		$this->Cell(195,5,$page." ".$this->PageNo(),0,1,'R',0);
		$this->Line(10,30,205,30);
		$this->Ln();
		$this->Ln();
		//Header
                
		//Column widths               
		$w=array(45,45,45,45);
		$this->SetFont('arialn','',8);

		$this->Cell($w[0],7,"BUDGET VOLUME (cbm)",1,0,'C',0);
		$this->Cell($w[1],7,"BUDGET WEIGHT (ton)",1,0,'C',0);
		$this->Cell($w[2],7,"BUDGET REVENUE (rupiah)",1,0,'C',0);
		$this->Cell($w[3],7,"BUDGET SHIPPING ",1,0,'C',0);
	 
		$this->Ln();
    }

    function ReportTable($Result) 
    {
		        
        //Column widths
        $w=array(45,45,45,45);
                
        //Data
        foreach($Result as $row)
        {

			$no++;
			
			$this->Cell($w[0],6,$row["budget_volume"],'LR',0,'C');
			$this->Cell($w[1],6,$row["budget_berat"],'LR',0,'C');
			$this->Cell($w[2],6,$row["budget_revenue"],'LR',0,'C');
			$this->Cell($w[3],6,$row["budget_shipping"],'LR',0,'C');
										
			$this->Ln();
			
        }


    }

    function Footer() {
        //Closure line
        $this->Cell(180,0,'','T');
    }

}


?>
